package com.example.actordemo1.life;

import akka.actor.AbstractActor;
import scala.Option;

import java.util.Optional;

public class LifeChildActor extends AbstractActor {

    @Override
    public void preStart() throws Exception {

        System.out.println("childlife  preStart ");
    }

//    @Override
//    public void aroundPreStart() {
//        System.out.println("childlife  aroundPreStart ");
//    }

    @Override
    public void postStop() throws Exception {
        System.out.println("childlife postStop   ");
    }

//    @Override
//    public void aroundPostStop() {
//        System.out.println("childlife  aroundPostStop ");
//    }

//    @Override
//    public void aroundPreRestart(Throwable reason, Option<Object> message) {
//        System.out.println("childlife  aroundPreRestart ");
//        super.aroundPreRestart(reason, message);
//    }

    @Override
    public void preRestart(Throwable reason, Option<Object> message) throws Exception {
        System.out.println("childlife  preRestart ");
        super.preRestart(reason, message);
    }

//    @Override
//    public void aroundPostRestart(Throwable reason) {
//        System.out.println("childlife  aroundPostRestart ");
//        super.aroundPostRestart(reason);
//    }

    @Override
    public void preRestart(Throwable reason, Optional<Object> message) throws Exception {
        System.out.println("childlife  preRestart ");
        super.preRestart(reason, message);
    }

    @Override
    public void postRestart(Throwable reason) throws Exception {
        System.out.println("childlife  postRestart ");
        super.postRestart(reason);
    }

    @Override
    public Receive createReceive() {
        return receiveBuilder().matchAny(o->{
            System.out.println(o);
        }).build();
    }
}
